import React from 'react';
// import styles from './index.module.scss';

import {ErrorBoundary} from '@/components';

import {ChartMap} from "../../charts/chartsMap";
import * as classnames from "classnames";

interface IProps {
  chartOption: DV.IChart,
  type: string,
}

interface IState {

}

/**
 * chart容器
 * 1、处理样式配置
 * 2、容器渲染
 * 3、组件识别分配
 * 4、数据加载
 * 5、框架依赖异步加载
 * @constructor
 */
export default class ChartContainer extends React.PureComponent<IProps, IState> {
  constructor(props: IProps) {
    super(props);

  }

  render(): React.ReactNode {
    const {uid, width, height, left, top, zIndex} = this.props.chartOption;
    return <div
      className={classnames('dv_chart_item')}
      id={`chart_${uid}`}
      style={{width, height, left, top, zIndex}}
    >

      <div className={'chart_item__content'}>
        {/*----图表实例渲染位置-------*/}
        <ErrorBoundary type={'chart'}>
          <ChartMap
            chartOption={this.props.chartOption}
          />
        </ErrorBoundary>
      </div>

    </div>
  }
}
